#include <algorithm>
#include <cstdio>
#include <tuple>
#include <vector>
int n;
std::vector<long long> v;
std::vector<std::tuple<long long, long long>> tpl;
int main()
{
    freopen("kte.in", "r", stdin);
    freopen("kte.out", "w", stdout);
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        long long x;
        scanf("%lld", &x);
        auto it = std::lower_bound(v.begin(), v.end(), x);
        if (it == v.end() || *it != x)
        {
            v.insert(it, x);
        }
        else
        {
            v.erase(it);
        }
        tpl.clear();
        long long left, right;
        left = right = 0;
        auto itl = v.begin();
        auto itr = v.end();
        itr--;
        for (; itl != v.end();)
        {
            left += *itl;
            right += *itr;
            tpl.push_back({left, right});
            itl++;
            itr--;
        }
        std::sort(tpl.begin(), tpl.end());
        long long answer = 0;
        long long cur = -0x7f7f'7f7f'7f7f'7f7f;
        for (const auto &[l, r] : tpl)
        {
            cur = std::max(cur, l);
            answer += r - cur;
            cur = r;
        }
        printf("%lld\n", answer);
    }
    return 0;
}
